<template>
  <van-sticky>
    <van-nav-bar
      title="标题"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
  </van-sticky>
  <div>
    <van-pull-refresh v-model="loading" @refresh="onRefresh">
      <van-card
        v-for="item in goodsList"
        :price="item.goods_price"
        :title="item.goods_name"
        :thumb="item.goods_small_logo"
        @click="xq(item.goods_id)"
      />
    </van-pull-refresh>
  </div>
</template>

<script setup>
const onClickLeft = () => router.go(-1);
import axios from "axios";
import { ref } from "vue";
import { useRoute, useRouter } from "vue-router";
const router = useRouter();
const route = useRoute();
const goodsList = ref([]);
axios
  .get("https://api-hmugo-web.itheima.net/api/public/v1/goods/search", {
    params: {
      goods_id: route.query.cid,
    },
  })
  .then((res) => {
    goodsList.value = res.data.message.goods;
  });
const xq = (cid) => {
  router.push({
    path: "/xq",
    query: {
      cid,
    },
  });
};
import { showToast } from 'vant';
//下拉刷新
 const count = ref(0);
    const loading = ref(false);
    const onRefresh = () => {
      setTimeout(() => {
        showToast('刷新成功');
        loading.value = false;
        count.value++;
      }, 1000);
    };
</script>

<style lang="scss" scoped>
</style>